const local = {
  getToken(key: string) {
    if (!key) {
      return
    }
    return window.localStorage.getItem(key)
  },
  get(key: string) {
    if (!key) {
      return
    }
    const data: string = window.localStorage.getItem(key) || ''
    return JSON.parse(data)
  },
  set(key: string, value: string) {
    if (!key) {
      return
    }
    if (typeof value !== 'string') {
      value = JSON.stringify(value)
    }
    window.localStorage.setItem(key, value)
  },
  clear() {
    window.localStorage.clear()
  },
  remove(key: string) {
    if (!key) {
      return
    }
    window.localStorage.removeItem(key)
  }
}
export default local
